Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle non-200 status codes with JSON payload in GitHub API responses #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zonia3000
Copy link

I encountered the following error on application startup:

thread 'main' panicked at src/main.rs:302:82:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: <pineflash::Flasher as eframe::epi::App>::update
   5: <eframe::native::glow_integration::GlowWinitApp as eframe::native::winit_integration::WinitApp>::run_ui_and_paint
   6: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
   7: winit::platform_impl::platform::x11::EventLoop<T>::run_on_demand
   8: eframe::run_native
   9: pineflash::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Debugging, I discovered that it was caused by the URL https://api.github.com/repos/Ralim/IronOS/releases replying as follow:

{
  "message": "API rate limit exceeded for XX.XX.XX.XX. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
  "documentation_url": "https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"
}

The code checks for invalid JSON but not for valid JSON with status code different than 200, as this case. I added a check for the status code too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant